<template>
    <button @click="Changeshow">展示弹窗</button>
    <teleport to="body">
        <div class="modal" v-if="isshow">
            <h2>我是标题</h2>
            <p>我是内容</p>
            <button>关闭弹窗</button>
    </div>
    </teleport>
</template>
<script lang="ts" setup name="Modal">
import {ref} from 'vue';
    let isshow=ref(false);
    function Changeshow(){
        isshow.value=!isshow.value
    }
</script>
<style scoped>
    .modal{
        width: 200px;
        height: 200px;
        background-color: skyblue;
        border-radius: 10px;
        padding: 5px;
        box-shadow: 0 0 5px;
        text-align: center;
        position: absolute;
        left: 50%;
        transform: translate(-50%); 
        top: 20px;
    }
</style>